![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
vue-progressive-image
Advanced tools
Readme
Vue progressive image loading plugin
$ npm install vue-progressive-image
import Vue from 'vue'
import VueProgressiveImage from 'vue-progressive-image'
Vue.use(VueProgressiveImage)
Instead of using the normal img
tag to load images
<img src="https://unsplash.it/1920/1080?image=10" />
use the progressive-img
component already globally available after the plugin installation
<progressive-img src="https://unsplash.it/1920/1080?image=10" />
It is also possible to apply progressive images as backgrounds and it will have the same props as the progressive-img component
<progressive-background src="https://unsplash.it/1920/1080?image=10" />
To be able to immediately show some feedback to the user, it is possible to pass a placeholder image, which could be also 1% the size of the main image: it will be blurred so you can go crazy with optimizations here.
in this example I actually use the same image, but you have the idea here
<progressive-img
src="https://unsplash.it/1920/1080?image=10"
placeholder="https://unsplash.it/1920/1080?image=10"
/>
This slot would be mainly use as a preloader slot, but could be used for whatever purpose.
The slot exposes a visible
property to be able to toggle its visibility based on when the image is preloading or it's rendered.
<progressive-img src="https://unsplash.it/1920/1080?image=10">
<div slot-scope="{ visible }" v-if="visible">
Loading the image...
</div>
</progressive-img>
It is possible to adjust the level of blur applied to the placeholder image
<progressive-img
src="https://unsplash.it/1920/1080?image=10"
placeholder="https://unsplash.it/1920/1080?image=10"
:blur="30"
/>
It is possible to remove the padding that adds the aspect ratio to the container.
<progressive-img
src="https://unsplash.it/1920/1080?image=10"
no-ratio
/>
It is also possible to manually specify the image aspact ratio when you know it. It allows the placeholder to be displayed in the correct aspect ratio. The ratio is calculated as height / width
.
<progressive-img
src="https://unsplash.it/1920/1080?image=10"
aspect-ratio="1.5"
/>
In case of a loading error of the main image, it is possible to add a fallback image which can display an error image or just another image.
<progressive-img
src="https://this_url_should_cause_an_error"
fallback="https://unsplash.it/1920/1080?image=10"
/>
Each component emits an event whenever an image is loaded.
Because we usually load two images, a main image and a placeholder, two events are dispatched onLoad
and onLoadPlaceholder
in your js file
export default {
methods: {
onLoad () {
// main image is loaded
},
onLoadPlaceholder () {
// placeholder image is loaded
},
onError (error) {
// main image error
},
onErrorPlaceholder (error) {
// placeholder image error
}
}
}
in the html just add the events you need to listen to
<progressive-img
@onLoad="onLoad"
@onLoadPlaceholder="onLoadPlaceholder"
@onError="onError"
@onErrorPlaceholder="onErrorPlaceholder"
src="https://unsplash.it/1920/1080?image=10"
placeholder="https://unsplash.it/1920/1080?image=10"
/>
During the installation process it is possible to pass some default global options
Vue.use(VueProgressiveImage, {
placeholder: 'https://unsplash.it/1920/1080?image=20'
})
Vue.use(VueProgressiveImage, {
blur: 30
})
This options is for debug only. It lets you have an easy look at the placeholder before the main image is fully loaded.
Vue.use(VueProgressiveImage, {
delay: 2000 // 2 seconds before the image is displayed
})
Global options like placeholder
and blur
will be applied only to components that don't specify their own options
Check out the example
folder in the root of the repository for a small vue page with some examples on how to use the plugin.
If you want to add some new example, just make a PR and I will add them :)
Please drop an issue, if you find something that doesn't work, or a feature request at https://github.com/MatteoGabriele/vue-progressive-image/issues
Follow me on twitter @matteo_gabriele
FAQs
Vue progressive image loading plugin
We found that vue-progressive-image demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.